

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <#include "../../include/layui.ftl" />
    <#include "../../include/pTable.ftl" />
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <form  id="queryForm">
                <input type="hidden" id="className" name="className" value="${className!}" />
                <input type="hidden" id="modleName" name="modleName" value="${modleName!}" />
                <input type="hidden"  name="createrId" value="${SESSION_USER.user.id!}" />
                <input type="hidden" name="createrId_searchType" value="eq">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">商户订单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="outTradeNo" placeholder="请输入" autocomplete="off" class="layui-input">
                            <input type="hidden" name="outTradeNo_searchType" value="like">
                        </div>
                    </div>
                </div>
            </form>
        </div>

        <div class="layui-card-body">

            <table id="lay-table" lay-filter="lay-table"></table>
            <script type="text/html" id="toolbar">
            </script>
        </div>

        <div class="layui-hide">
            <table  id="lay-excal-table" lay-filter="lay-excal-table"></table>
        </div>

    </div>
</div>
<script>
    layui.config({
        base: '${path}/plug-in/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','tables','layers','view','excels'],function () {
        var tables = layui.tables,
            table = layui.table,
            view = layui.view,
            layer = layui.layer,
            layers = layui.layers,
            excels = layui.excels,
            $ = layui.$;

        var parmer = {
            url:'/console/order/rewrite/list',
            defaultToolbar: ['filter',{
                title: '导出' //标题
                ,layEvent: 'LAYTABLE_TIPS' //事件名，用于 toolbar 事件中使用
                ,icon: 'layui-icon-export' //图标类名
            }],
            where:{sort : 'create_time',order:'desc',createrId:"${SESSION_USER.user.id!}",createrId_searchType:"eq" ,noPage:false},
            cols:[[
                    {field:"outTradeNo",width:170,title:"商户订单号"}
                    ,{field:"orderName",width:130,title:"订单名称"}
                    ,{field:"nickName",width:120,title:"用户昵称"}
                    ,{field:"mobile",width:120,title:"手机号码"}
                    ,{field:"transactionId",width:250,title:"支付订单号"}
                    ,{field:"totalFee",width:120,title:"订单金额(元)",templet:function(d){
                        return d.totalFee / 100;
                    }}
                    ,{field:"orderType",width:90,title:"订单类型",templet:function(d){
                        var valArr = ['支付', '充值'];
                        return valArr[d.orderType];
                    }}
                    ,{field:"checkNumber",width:90,title:"充值次数"}
                    ,{field:"tradeType",width:120,title:"支付类型",templet:function (d) {
                        var val = "";
                        if (d.tradeType == 'JSAPI') val = "小程序支付";
                        if (d.tradeType == 'NATIVE') val = "二维码支付";
                        if (d.tradeType == 'APP') val = "APP支付";
                        return val;
                    }}
                  /*  ,{field:"resultCode",width:'8%',title:"支付结果",templet:function (d) {
                        var val = "<span style='color:orange;'>支付中</span>";
                        if (d.resultCode == 'SUCCESS') val = "<span style='color:green;'>成功</span>";
                        if (d.resultCode == 'FAIL') val = "<span style='color:red;'>失败</span>";
                        return val;
                    }}*/
                    ,{field:"orderStatus",width:120,title:"订单状态",templet:function(d){
                        var val = "";
                        if (d.orderStatus == 'SUCCESS') val = "<span style='color:green;'>支付成功</span>";
                        if (d.orderStatus == 'PAYERROR') val = "<span style='color:red;'>支付失败</span>";
                        if (d.orderStatus == 'REFUND') val = "<span style='color:red;'>转入退款</span>";
                        if (d.orderStatus == 'CLOSED') val = "<span style='color:red;'>已关闭</span>";
                        if (d.orderStatus == 'REVOKED') val = "<span style='color:red;'>已撤销</span>";
                        if (d.orderStatus == 'USERPAYING') val = "<span style='color:orange;'>支付中</span>";
                        if (d.orderStatus == 'NOTPAY') val = "<span style='color:red;'>未支付</span>";
                        return val;
                    }}
                    ,{field:"timeEnd",width:180,title:"支付完成时间"}
                ]]
        };
        var $tables = tables.renderTable(parmer);

        var excel_parmer = JSON.parse(JSON.stringify(parmer));
        //excel_parmer = $.extend({},excel_parmer,parmer);
        excel_parmer.id = "lay-excal-table";
        excel_parmer.elem = "#lay-excal-table";
        excel_parmer.where.noPage = true;
        excel_parmer.page = false;
        var $excelTables = tables.renderTable(excel_parmer);

        //头工具栏事件
        table.on('toolbar(lay-table)', function(obj){
            switch(obj.event){
                case 'LAYTABLE_TIPS':
                    excels.exportFile("lay-excal-table","订单数据");
                    break;
                case '05':
                    var where = $("#queryForm").serializeObject();
                    where = $.extend({}, $tables.config.where, where);
                    $tables.reload({
                        where: where,
                        text: {none: '暂无数据！'}
                    });
                    $excelTables.reload({
                        where: where,
                        text: {none: '暂无数据！'}
                    });
                    break;
            };
        });

    });
</script>
</body>
</html>